package huawei.exam4;

import java.util.ArrayList;
import java.util.Comparator;
import java.util.List;
import java.util.Scanner;
import java.util.stream.Collectors;

/**
 * @author : Rookie
 * @description :
 * @date : 2023/1/4
 */
public class HJ92 {

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        while (scanner.hasNextLine()) {
            String str = scanner.nextLine();
            List<String> strings = new ArrayList<>();
            StringBuilder sb = new StringBuilder();
            for (int i = 0; i < str.length(); i++) {
                char c = str.charAt(i);
                if ( i != str.length() - 1) {
                    if (Character.isDigit(c)) {
                        sb.append(c);
                    } else {
                        strings.add(sb.toString());
                        sb = new StringBuilder();
                    }
                } else {
                    if (Character.isDigit(c)) {
                        sb.append(c);
                        strings.add(sb.toString());
                    }
                }

            }

            List<String> sortList = strings.stream().filter(s -> !s.isEmpty()).sorted(Comparator.comparingInt(String::length))
                    .collect(Collectors.toList());

            List<Integer> lengths = sortList.stream().map(String::length).collect(Collectors.toList());

            int maxLength = sortList.stream().max(Comparator.comparingInt(String::length)).get().length();

            StringBuffer stringBuffer = new StringBuffer();
            for (int i = 0; i < lengths.size(); i++) {
                if (lengths.get(i) == maxLength) {
                    stringBuffer.append(sortList.get(i));
                }
            }
            stringBuffer.append(",").append(maxLength);
            System.out.println(stringBuffer);
        }
    }
}
